/**
 * @(#) RegNoCheckMediator.as(사용안함)
 *
 * @date		2010. 11. 01
 * @version		2.0
 * @author		Shin, Yunwoo
 * @client		Service Ace 
 * @module		Compensation  (급여)
 * @description	급여 주민번호 체크   - Mediator
 * 				
 */
package com.skt.common_hr.compensation.view
{
	import com.skt.common_hr.common.Variables;
	import com.skt.common_hr.common.components.CommonAlert;
	import com.skt.common_hr.common.puremvc.CommonMediator;
	import com.skt.common_hr.compensation.CompensationFacade;
	import com.skt.common_hr.compensation.model.RegCheckProxy;
	import com.skt.common_hr.compensation.view.components.RegNoCheckView;
	
	import flash.events.Event;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	
	public class RegNoCheckMediator extends CommonMediator
	{
		public static const NAME:String = "RegNoCheckMediator"; 



		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function RegNoCheckMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );
        }
 		
		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
 		override protected function initializeView():void
 		{
 			var proxy:RegCheckProxy = facade.retrieveProxy(RegCheckProxy.NAME) as RegCheckProxy;
 			proxy.load(Variables.myPernr);

 			view.addEventListener(RegNoCheckView.Submit, onCheckSubmit);
 		}
 		

	
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		* 본 Class에서 처리해야할 Noti들을 등록한다.
		* 
		* @param
		* @return void
		*/
		override public function listNotificationInterests():Array 
		{
			return [
					CompensationFacade.LOAD_REGNO_COMPLETE,
					CompensationFacade.LOAD_REGNO_FAILED,
					CompensationFacade.VALID_REGNO,
					CompensationFacade.INVALID_REGNO
					];
		}
		

		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		override public function handleNotification(note:INotification):void
		{
			switch(note.getName()) 
			{
				case CompensationFacade.LOAD_REGNO_COMPLETE:
					view.regNo1 = (note.getBody() as RegCheckProxy).regNo;
					break;
				case CompensationFacade.VALID_REGNO:
					facade.sendNotification(CompensationFacade.CONFORM_REGNO_CHECK, this);
					break;
				case CompensationFacade.INVALID_REGNO:
					CommonAlert.showMessage(commonFacade.bundle, "주민번호가 맞지 않습니다. 다시 입력해주십시오");
					break;
				default:
					//trace(this.instanceID+"에서 처리 안된 Noti가 검출됨 : " + note.getBody());
					break;
			}
		}



		private function onCheckSubmit(event:Event):void
		{
 			var proxy:RegCheckProxy = facade.retrieveProxy(RegCheckProxy.NAME) as RegCheckProxy;
 			proxy.checkRegNo(Variables.myPernr, view.txtRegNo.text);
		}




		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Utility Functions
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
        private function get view():RegNoCheckView
        {
            return viewComponent as RegNoCheckView;
        }
	}
}